# -*-* encoding:UTF-8 -*-
# author : mengy
# date   : 2018/11/22

import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr

acount = "1215012319@qq.com"
code = "vzddgnrijvuhhfff"
receivers = ['mengyanyuan@outlook.com', '1215012319@qq.com']

host = "smtp.qq.com"
port = 465


def mail():
    ret = True
    try:
        msg = MIMEText("邮件内容", "plain", "utf-8")
        msg['Form'] = formataddr(["python Tester", acount])
        msg['To'] = formataddr(["receiver", receivers])
        msg['Subject'] = "python 第三方邮件测试"

        server = smtplib.SMTP_SSL(host, port)
        server.login(acount, code)
        server.sendmail(acount, receivers, msg.as_string())
        server.quit()
        print("邮件发送成功")
    except Exception as e:
        print("邮件发送失败，", e)
        ret = False
    return ret


ret = mail()
